﻿Imports System.Management.Automation
Imports System.ComponentModel


<Cmdlet("clear", "host")> _
Public Class ClearHost
    Inherits Cmdlet

    Protected Overrides Sub EndProcessing()
        UIEvents.Add(New UIAction("ClearHost"))
    End Sub
End Class

<Cmdlet("New", "Tree")> _
Public Class NewTree
    Inherits Cmdlet
    Private _treename As String
    <Parameter(Position:=0)> _
    Public Property TreeName() As String
        Get
            Return _treename
        End Get

        Set(ByVal value As String)
            _treename = value
        End Set
    End Property
    Protected Overloads Overrides Sub EndProcessing()
        UIEvents.Add(New UIAction("NewTree", _treename))
        MyBase.EndProcessing()
    End Sub

End Class
<Cmdlet("new", "treenode")> _
Public Class NewTreeNode
    Inherits Cmdlet

    Private _nodename As String = ""
    Private _parentnodename As String = ""
    Private _object As PSObject = Nothing
    Private _parentobject As PSObject = Nothing
    Private _treename As String = ""

    <Parameter(Position:=0)> _
    Public Property NodeName() As String
        Get
            Return _nodename
        End Get

        Set(ByVal value As String)
            _nodename = value
        End Set

    End Property
    <Parameter(Position:=1)> _
    Public Property ParentNodeName() As String
        Get
            Return _parentnodename
        End Get

        Set(ByVal value As String)
            _parentnodename = value
        End Set

    End Property

    <Parameter(Position:=2)> _
     Public Property NodeObject() As PSObject
        Get
            Return _object
        End Get

        Set(ByVal value As PSObject)
            _object = value
        End Set

    End Property
    <Parameter(Position:=4)> _
 Public Property ParentObject() As PSObject
        Get
            Return _parentobject
        End Get

        Set(ByVal value As PSObject)
            _parentobject = value
        End Set

    End Property
    <Parameter(Position:=3)> _
  Public Property TreeName() As String
        Get
            Return _treename
        End Get

        Set(ByVal value As String)
            _treename = value
        End Set

    End Property
    Protected Overloads Overrides Sub EndProcessing()
        Dim ac As New UIAction("NewTreeNode")
        ac.strings("NodeName") = _nodename
        ac.objects("NodeObject") = _object
        ac.strings("ParentName") = _parentnodename
        ac.objects("ParentObject") = _parentobject
        ac.strings("TreeName") = _treename
        UIEvents.Add(ac)
    End Sub


End Class

<Cmdlet("Clear", "Tree")> _
Public Class ClearTree
    Inherits Cmdlet
    Private _treename As String
    <Parameter(Position:=0)> _
    Public Property TreeName() As String
        Get
            Return _treename
        End Get

        Set(ByVal value As String)
            _treename = value
        End Set
    End Property
    Protected Overloads Overrides Sub EndProcessing()
        UIEvents.Add(New UIAction("ClearTree", _treename))
        MyBase.EndProcessing()
    End Sub

End Class
<Cmdlet("Remove", "Tree")> _
Public Class RemoveTree
    Inherits Cmdlet
    Private _treename As String
    <Parameter(Position:=0)> _
    Public Property TreeName() As String
        Get
            Return _treename
        End Get

        Set(ByVal value As String)
            _treename = value
        End Set
    End Property
    Protected Overloads Overrides Sub EndProcessing()
        UIEvents.Add(New UIAction("RemoveTree", _treename))
        MyBase.EndProcessing()
    End Sub

End Class
<Cmdlet("New", "TypeMenuItem")> _
Public Class NewTypeMenuItem
    Inherits Cmdlet
    Private _typename As String
    Private _action As Object
    Private _name As String
    <Parameter(Position:=0)> _
    Public Property TypeName() As String
        Get
            Return _typename
        End Get

        Set(ByVal value As String)
            _typename = value
        End Set
    End Property
    <Parameter(Position:=1)> _
    Public Property Name() As String
        Get
            Return _name
        End Get
        Set(ByVal value As String)
            _name = value
        End Set
    End Property
    <Parameter(Position:=2)> _
    Public Property Action() As Object
        Get
            Return _action
        End Get
        Set(ByVal value As Object)
            _action = value
        End Set
    End Property
    Protected Overloads Overrides Sub EndProcessing()
        Dim ac As New UIAction("NewTypeMenuItem", _typename)
        ac.objects("Action") = _action
        ac.strings("Name") = _name
        UIEvents.Add(ac)
        MyBase.EndProcessing()
    End Sub

End Class